﻿<Window x:Class="FatController.WindowMain"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:ut="clr-namespace:Cleverscape.UTorrentClient.WebClient;assembly=Cleverscape.UTorrentClient.WebClient"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:FatController"
    Title="The Fat Controller" Height="516.615" Width="984.346" Name="WindowMainWindow" Icon="/FatController;component/TheFatController.ico">
    <Window.Resources>
        <local:TimeSpanDisplayConverter x:Key="TimeSpanConvert" />
        <local:QueuePriorityDisplayConverter x:Key="QueuePriorityConvert" />
        <local:SizeBytesDisplayConverter x:Key="SizeConverter" />
        <local:SizeBytesShowZeroDisplayConverter x:Key="SizeShowZeroConverter" />
        <local:SpeedBytesDisplayConverter x:Key="SpeedConverter" />
        <local:SeedPeerRatioDisplayConverter x:Key="SeedPeerRatioConverter" />
        <local:StatusDisplayConverter x:Key="StatusConverter" />
        <local:StatusImageDisplayConverter x:Key="StatusImageConverter" />

        <Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ProgressBar}">
                        <Grid MinHeight="14" MinWidth="50">
                            <Border Name="PART_Track" CornerRadius="0" Background="#00FFFFFF" BorderBrush="#FFF0F0F0" BorderThickness="1" />
                            <Border Name="PART_Indicator" CornerRadius="0" Background="#FFA0A0FF" BorderBrush="#00FFFFFF" BorderThickness="0" HorizontalAlignment="Left" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>


    <Grid>
        <ToolBarTray Height="36" VerticalAlignment="Top" OverridesDefaultStyle="False">
            <ToolBar Band="1" BandIndex="1" Grid.IsSharedSizeScope="False" Visibility="Visible">
                <Button Click="AddFileButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar1AddFile.png" />
                </Button>
                <Button Click="AddAddressButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar2AddAddress.png" />
                </Button>
            </ToolBar>
            <ToolBar Band="1" BandIndex="2">
                <Button Click="RemoveButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar3Remove.png" />
                </Button>
            </ToolBar>
            <ToolBar Band="1" BandIndex="3">
                <Button Click="PlayButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar4Play.png" />
                </Button>
                <Button Click="PauseButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar5Pause.png" />
                </Button>
                <Button Click="StopButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar6Stop.png" />
                </Button>
            </ToolBar>
            <ToolBar Band="1" BandIndex="4">
                <Button Click="SettingsButton_Click">
                    <Image Height="24" Width="24" Source="/FatController;component/Resources/ToolBar8Settings.png" />
                </Button>
            </ToolBar>
        </ToolBarTray>
        <dg:DataGrid Name="DataGridTorrents" Margin="0,36,0,0" AutoGenerateColumns="False" ItemsSource="{Binding}" BorderThickness="0" GridLinesVisibility="None" 
                     RowDetailsVisibilityMode="Collapsed" FontSize="11.5" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" VerticalContentAlignment="Center">
            <dg:DataGrid.Columns>
                <dg:DataGridTemplateColumn Header="Name" SortMemberPath="Name" IsReadOnly="True" >
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel CanHorizontallyScroll="False" CanVerticallyScroll="False" FlowDirection="LeftToRight" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                                <Image Height="16" Width="16" Source="{Binding Mode=OneWay, Path=SimpleStatus, Converter={StaticResource StatusImageConverter}}" />
                                <TextBlock Text="{Binding Mode=OneWay, Path=Name}" />
                            </StackPanel>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=QueueOrder, Converter={StaticResource QueuePriorityConvert}}" Header="#" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeTotalBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Size" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeDownloadedBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Downloaded" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeRemainingBytes, Converter={StaticResource SizeConverter}}" Header="Remaining" IsReadOnly="True" />
                <dg:DataGridTemplateColumn Header="Done" SortMemberPath="ProgressPercent" IsReadOnly="True" >
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <ProgressBar BorderThickness="1" BorderBrush="#FFF0F0F0" Maximum="1" Minimum="0" Value="{Binding Mode=OneWay, Path=ProgressPercent}" Background="White" Foreground="#FF5050FF" SmallChange="0.001">
                                </ProgressBar>
                                <TextBlock Text="{Binding Mode=OneWay, Path=ProgressPercent, StringFormat=0.0%}" TextAlignment="Center" />
                            </Grid>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SimpleStatus, Converter={StaticResource StatusConverter}}" Header="Status" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Seeds}" SortMemberPath="SeedsTotal" Header="Seeds" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Peers}" SortMemberPath="PeersTotal" Header="Peers" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SeedsPeersRatio, Converter={StaticResource SeedPeerRatioConverter}}" Header="Seeds/Peers" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SpeedDownloadBytes, Converter={StaticResource SpeedConverter}}" Header="Down Speed" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SpeedUploadBytes, Converter={StaticResource SpeedConverter}}" Header="Up Speed" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=TimeEstimate, Converter={StaticResource TimeSpanConvert}}" Header="ETA" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeUploadedBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Uploaded" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SeedRatio, StringFormat=0.000}" Header="Ratio" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Availability, StringFormat=0.000}" Header="Avail." IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Label}" Header="Label" IsReadOnly="True" />
            </dg:DataGrid.Columns>
        </dg:DataGrid>

    </Grid>
</Window>
